<template>
	<view class="mall page p10 bgf7">
		<view class="bgff p16">
			<view class="head flex flexC">
				<button class="btn" open-type="chooseAvatar" @chooseavatar="onChooseavatar">
					<image class="avatar r50" :src="logo" mode="aspectFill"></image>
				</button>
				<view class="fs14 ml10 flex1">{{data.name}}</view>
				<button @click="openShop" class="btnShare fs14 r40">店铺分享</button>
			</view>
			<view class="aliC fs13 flex flexC flexB mt12">
				<view class="w32">
					<view class="bold6 fs26">{{todayProfit}}</view>
					<view>今日收益</view>
				</view>
				<view class="w32">
					<view class="bold6 fs26">{{yesProfit}}</view>
					<view class="mt2">昨日收益</view>
				</view>
				<view class="w32">
					<view class="bold6 fs26">{{order}}</view>
					<view>今日订单数</view>
				</view>
			</view>

		</view>
		<view class="bgff p16 my10">
			<view class="fs16 c00 bold6">数据管理</view>
			<view class="aliC fs13 flex flexC flexB mt12">
				<view class="w32" @click="lookGood">
					<view class="bold6 fs26">{{goods}}</view>
					<view>商品数</view>
				</view>
				<view class="w32">
					<view class="bold6 fs26">￥{{amount}}</view>
					<view>销售额</view>
				</view>
				<view class="w32" @click="lookOrder">
					<view class="bold6 fs26">{{allOrder}}</view>
					<view>订单数</view>
				</view>
			</view>
		</view>
	<!-- 	<view class="bgff p16">
			<view class="fs16 c00 bold6">店铺管理</view>
			<view class="aliC fs13 flex flexC flexB mt12">
				<view class="w32">
					<image class="icon" src="/static/img/icon/log.png" mode="aspectFill"></image>
					<view>配送设置</view>
				</view>
				<view class="w32">
					<image class="icon" src="/static/img/icon/sucai.png" mode="aspectFill"></image>
					<view>活动素材</view>
				</view>
				<view class="w32">
					<image class="icon" src="/static/img/icon/fenxiao.png" mode="aspectFill"></image>
					<view>分销设置</view>
				</view>
			</view>
		</view> -->
		
		<tabbar></tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				logo:'/static/logo.jpg',
				data:null,
				todayProfit:0,
				yesProfit:0,
				order:0,
				amount:0,
				goods:0,
				allOrder:0
			}
		},
		onLoad() {
			uni.hideHomeButton();
			
			this.getIndex();
		},
		methods: {
			
			
			openShop(){
				
				uni.navigateToMiniProgram({
				  appId: 'wx98126d706532d3e4',
				  path: 'pages/home/index?shop_id='+uni.getStorageSync("shop_id")+"&mobile="+uni.getStorageSync("mobile"),
				  extraData: {
				    'data1': 'test'
				  },
				  success(res) {
				    // 打开成功
				  }
				})	
			},
			
			lookGood(){
				uni.navigateTo({
					url:'../mall/sysProduct'
				})
			},
			lookOrder(){
				uni.navigateTo({
					url:'../mall/orderList'
				})
			},

			getIndex() {

				let param = {
					shop_id: uni.getStorageSync("shop_id")
				}
				let that = this;
				this.$api.onlineIndex(param).then(res => {

					if (res.code == 1) {

						that.data = res.data;
						if (res.data.logo != '') {
							that.logo = res.data.logo;
						}
						that.todayProfit = res.data.todayProfit;
						that.yesProfit = res.data.yesProfit;
						that.order = res.data.order;
						that.amount = res.data.amount;
						that.goods = res.data.goods;
						that.allOrder = res.data.allOrder;
					} else {

					}

				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.mall {
		.icon {
			width: 80rpx;
			height: 80rpx;
		}

		.w32 {
			width: 32%;
		}

		.head {
			.btn {
				.avatar {
					width: 104rpx;
					height: 104rpx;
				}
			}

			.btnShare {
				color: #FD449B;
				border: 2rpx solid #FD449B;
				width: 172rpx;
				height: 68rpx;
				line-height: 68rpx;
			}
		}
	}
</style>